<%--
  Created by IntelliJ IDEA.
  User: 86150
  Date: 2022/10/27
  Time: 17:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css" >
    <script src="${pageContext.request.contextPath}/static/echarts.js"></script>
    <script src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
</head>
<body>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit" >添加回访</a>
</script>
<form class="layui-form" action="" id="SCLFrom" style="display: none" lay-filter="updateSCLFormFilter">
    <input type="hidden" name="id" id="rid">
    <input type="hidden" name="username" id="rusername">
    <input type="hidden" name="tel" id="tel">
  <%--  <form class="layui-form" action="" >--%>
        <div class="registerbox-title">回访记录修改</div>
        <div class="layui-form-item">
            <label class="layui-form-label">回访人</label>
            <div class="layui-input-inline">
                <input  type="textarea" name="username"  lay-verify="required" placeholder="请输入回访人" autocomplete="off"
                        class="layui-input" >
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">回访内容</label>
            <div class="layui-input-inline">
                <textarea  type="textarea" style="height: 100px" name="recond" id="recond"  lay-verify="required" placeholder="请输入回访内容" autocomplete="off"
                           class="layui-input"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-inline">
                <textarea  type="textarea" style="height: 100px" name="remark" id="remark" lay-verify="required" placeholder="请输入备注" autocomplete="off"
                           class="layui-input"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="updateTest">添加</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
<%--    </form> --%>
</form>
<div>
    <div id="right" style="width: 1350px; float: left">
        <h2 style="font-family: 隶书;text-align: center;font-size: 30px;margin: 20px 20px">心理健康SCL测试结果分析统计表</h2>
        <%--查询框--%>
        <%--查询条件--%>
        <form class="layui-form" action="">
            <div class="layui-inline">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-inline">
                    <input type="text" name="username" placeholder="请输入用户名" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">电话</label>
                <div class="layui-input-inline">
                    <input type="text" name="tel" placeholder="请输入电话号码" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <button class="layui-btn" lay-submit lay-filter="formDemo">查询</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
        <%--查询条件结束--%>
        <%--存放一个table--%>
        <table class="layui-hide" id="test2" lay-filter = "test2">
        </table>
    </div>

</div>
<script>
    layui.use(['table','layer','form','jquery','tree'], function(){
        var tree = layui.tree;
        var table = layui.table;
        var layer = layui.layer;
        var form = layui.form;
        var $ = layui.jquery;
        var namestatus=true;
        table.render({
            // element  元素
            elem: '#test2'
            ,page:true
            ,limit:10
            ,limits:[10,20,30]
            ,toolbar: '#toolbarDemo'
            ,url:'${pageContext.request.contextPath}/sclRecord/tj' //  表格了里面所需要的数据就是一个list里面有很多的map、对象
            ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            // ,parseData: function (res) {
            //     //alert(JSON.stringify(res.data));
            //     return {
            //         "code": res.code,
            //         "msg": res.msg,
            //         "count": res.data.total,//从返回的json数据中取出总行数
            //         "data": res.data.list//返回的json数据有两层，layui不支持多层数据，所以是res.list
            //     }
            // }
            ,cols: [[
                 {type: 'checkbox', fixed: 'left' }
                // field 后面跟的内容  必须跟后台传过来的数据里面的map 的key保持一致
                ,{field:'id', title: 'ID', sort: true}
                ,{field:'username', title: '用户名', sort: true}
                ,{field:'tel', title: '电话', sort: true}
                ,{field:'F1', title: 'F1躯体化', sort: true}
                ,{field:'F2', title: 'F2强迫', sort: true}
                ,{field:'F3', title: 'F3人际关系', sort: true}
                ,{field:'F4', title: 'F4抑郁', sort: true}
                ,{field:'F5', title: 'F5焦虑', sort: true}
                ,{field:'F6', title: 'F6敌对性', sort: true}
                ,{field:'F7', title: 'F7恐怖', sort: true}
                ,{field:'F8', title: 'F8偏执', sort: true}
                ,{field:'F9', title: 'F9精神病性', sort: true}
                ,{field:'F10', title: 'F10睡眠及饮食', sort: true}
                ,{field:'createtime', title: '测试时间', sort: true}
                ,{fixed: 'right', title:'操作', width: 170, minWidth: 125, toolbar: '#barDemo'}
            ]]
        });

        // 查询
        form.on('submit(formDemo)', function(data){
            table.reload('test2', {
                where: data.field,
                page: {
                    curr: 1 //重新从第 1 页开始
                },
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

        //触发单元格工具事件
        //监听行工具事件
        table.on('tool(test2)', function(obj){
            var data = obj.data;
            if(obj.event === 'edit'){
                $(".pass").css("display","none");
                layer.open({
                    type: 1,
                    area: ['500px', '400px'],
                    offset: '100px',
                    content:$("#SCLFrom"),
                    cancel: function(index, layero){
                        layer.close(index);
                        $("#SCLFrom").hide();
                        return false;
                    }
                });
                //获取表单行中的数据
                form.val('updateSCLFormFilter',data);
            }
        });
        form.on('submit(updateTest)', function(data){
            var rid = $("#rid").val();
            var rusername = $("#rusername").val();
            var tel = $("#tel").val();
            var recond = $("#recond").val();
            var remark = $("#remark").val();
            alert(rid+rusername+tel+recond+remark);
            var params={};
            params.rid=rid;
            params.rusername=rusername;
            params.tel= tel;
            params.recond = recond;
            params.remark = remark;
            if(namestatus){
                $.ajax({
                    type:"post",
                    dataType:"JSON",
                    data:params,//表单里所有数据
                    url:"${pageContext.request.contextPath}/sclRecondTest/addAndupd",
                    success:function (ret){
                        alert(ret.data)
                        if (ret.data == true){
                            //关闭所有弹框
                            layer.closeAll();
                            //刷新页面
                            //table.reload('test');
                            $("#saveUserForm").hide();
                        }
                    }
                })
            }
            return false;
        });
    });
</script>
</body>
</html>
